const express = require('express');
const router = express.Router();
const purchaseListController = require('../controllers/purchaseListController');

/**
 * @swagger
 * tags:
 *   name: 采购清单管理
 *   description: 采购清单的增删改查接口
 */

/**
 * @swagger
 * /api/purchaseList:
 *   get:
 *     summary: 获取所有采购清单
 *     tags: [采购清单管理]
 *     responses:
 *       200:
 *         description: 返回采购清单数组
 */
router.get('/', purchaseListController.getAll);

/**
 * @swagger
 * /api/purchaseList/{id}:
 *   get:
 *     summary: 根据ID获取采购清单详情
 *     tags: [采购清单管理]
 *     parameters:
 *       - name: id
 *         in: path
 *         required: true
 *         description: 采购清单ID
 *         schema:
 *           type: integer
 *     responses:
 *       200:
 *         description: 返回单个采购清单对象
 */
router.get('/:id', purchaseListController.getById);

/**
 * @swagger
 * /api/purchaseList:
 *   post:
 *     summary: 创建新的采购清单
 *     tags: [采购清单管理]
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               name:
 *                 type: string
 *                 description: 材料名称
 *               supplier:
 *                 type: integer
 *                 description: 供应商编号
 *               quantity:
 *                 type: integer
 *                 description: 数量
 *     responses:
 *       200:
 *         description: 创建成功
 */
router.post('/', purchaseListController.create);

/**
 * @swagger
 * /api/purchaseList/{id}:
 *   put:
 *     summary: 更新采购清单
 *     tags: [采购清单管理]
 *     parameters:
 *       - name: id
 *         in: path
 *         required: true
 *         description: 采购清单ID
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *     responses:
 *       200:
 *         description: 更新成功
 */
router.put('/:id', purchaseListController.update);

/**
 * @swagger
 * /api/purchaseList/{id}:
 *   delete:
 *     summary: 删除采购清单（逻辑删除）
 *     tags: [采购清单管理]
 *     parameters:
 *       - name: id
 *         in: path
 *         required: true
 *         description: 采购清单ID
 *     responses:
 *       200:
 *         description: 删除成功
 */
router.delete('/:id', purchaseListController.delete);

module.exports = router;
